package com.firexxx.vp.adapter.scheduled;

import com.firexxx.common.domain.query.CacheConsistencyInterface;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2020/02/15 20:11
 */
@Component
@Slf4j
public class CacheSynchronizationManager {

    @Getter
    @Setter
    private List<CacheConsistencyInterface> cacheBeanList = new ArrayList<>();

    @Scheduled(cron = "${cache.refresh:0 0 0/1 * * ?}")
    public void cacheSynchronization() {
        for (CacheConsistencyInterface cacheConsistencyInterface : cacheBeanList) {
            cacheConsistencyInterface.consistency();
        }
    }

}